import React, { useEffect } from 'react';
import { Form, FormInstance, Input } from 'antd';

type Props = {
    form: FormInstance;
    categoryName?: string;
};

// 更新分类的form组件
const UpdateForm: React.FC<Props> = ({ form, categoryName }) => {
    useEffect(() => {
        form.setFieldsValue({
            categoryName
        });
    }, [categoryName, form]);
    return (
        <Form form={form}>
            <Form.Item name="categoryName" rules={[
                {
                    required: true,
                    message: '分类名称必须输入.'
                }
            ]}>
                <Input type="text" placeholder="请输入分类名称" />
            </Form.Item>
        </Form>
    );
};

export default UpdateForm;